﻿using System;

namespace Taste
{
    /// <summary>
    /// Represents an error raised during a state and lets you decide how to handle it.
    /// </summary>
    /// <typeparam name="TState"></typeparam>
    public interface IStateError<TState>
        where TState : struct
    {
        /// <summary>
        /// The error raised during the current state.
        /// </summary>
        Exception Error { get; }

        /// <summary>
        /// Handles the error by specified the next state to enter, with the optional custom data.
        /// </summary>
        /// <param name="nextStateName">The next state to enter.</param>
        /// <param name="userData">The optional custom data for this state.</param>
        void HandleError(TState nextStateName, object userData = null);
    }
}
